GO
/****** Object:  Table [dbo].[aspnet_Cookie]    Script Date: 01/26/2008 18:30:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[aspnet_Cookie](
	[UID] [uniqueidentifier] NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[Value] [varbinary](max) NULL,
	[UpdateDateTime] [datetime] NULL,
	[ExpireDateTime] [datetime] NULL,
 CONSTRAINT [PK_aspnet_Cookie] PRIMARY KEY CLUSTERED 
(
	[UID] ASC,
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

USE [aspnetdb]
GO
/****** Object:  StoredProcedure [dbo].[aspnet_Cookie_Load]    Script Date: 01/26/2008 18:31:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[aspnet_Cookie_Load] 
	-- Add the parameters for the stored procedure here
@UID uniqueidentifier,
@Name varchar(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
select value from aspnet_Cookie where uid=@uid and name=@name and expiredatetime>=getdate()
end

USE [aspnetdb]
GO
/****** Object:  StoredProcedure [dbo].[aspnet_Cookie_Save]    Script Date: 01/26/2008 18:31:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[aspnet_Cookie_Save] 
	-- Add the parameters for the stored procedure here
@UID uniqueidentifier,
@Name varchar(50),
@Value varbinary(max),
@ExpireDays int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    -- Insert statements for procedure here
declare @UpdateDateTime datetime,@ExpireDateTime datetime
set @UpdateDateTime=getdate()
set @expiredatetime=dateadd(dd,@expiredays,@updatedatetime)
if(exists(select * from aspnet_cookie where uid=@uid and name=@name))
	update aspnet_cookie set value=@value,updatedatetime=@updatedatetime,expiredatetime=@expiredatetime  where uid=@uid and name=@name
else
	insert aspnet_Cookie (uid,name,value,updatedatetime,expiredatetime) values(@uid,@name,@value,@updatedatetime,@expiredatetime)
END
